See Also

SegmentedStream Class  | SegmentedStream Members  | Overload List

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Language

Visual Basic

C#

C++

C++/CLI

Show All

buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
count
The exact number of bytes to read.
fill
Always true, use this version of Read to completely fill the buffer
See Also Languages PowerTCP SSL Sockets for .NET

Read(Byte[],Int32,Int32,Boolean) Method

Dart.PowerTCP.SslSockets Namespace > SegmentedStream Class > Read Method : Read(Byte[],Int32,Int32,Boolean) Method

Read data from the stream until a byte array is filled.

[Visual Basic]
Overloads Public Function Read( _    ByVal buffer() As Byte, _    ByVal offset As Integer, _    ByVal count As Integer, _    ByVal fill As Boolean _ ) As Integer
[C#]
public int Read(    byte[] buffer,    int offset,    int count,    bool fill );
[C++]
public: int Read(    byte[]* buffer,    int offset,    int count,    bool fill )
[C++/CLI]
public: int Read(    bytearray<buffer>^ buffer,    int offset,    int count,    bool fill )

Parameters

buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
count
The exact number of bytes to read.
fill
Always true, use this version of Read to completely fill the buffer

Return Type

The total number of bytes read into the buffer. This will either be the value of the count parameter, or zero if the stream has closed.

Exceptions

ExceptionDescription
IOExceptionThrown when the stream is not Readable.
ArgumentNullExceptionThrown when the receiving buffer is null.
ArgumentOutOfRangeExceptionThrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentExceptionThrown when (offset + count) > buffer.Length.
EndOfStreamException Thrown when the end of the stream was found before the required byte count was received. When this occurs the Available property will indicate how much data may be read and the CanRead Property will return true.

Remarks

This method reads data from the stream and returns when the provided buffer is completely full or end of stream is reached. This method is a good way to read fixed-length data. An example of this is with HTTP chunking, which occurs when the server breaks up the HTTP response into fixed-size chunks. Each chunk is preceded with a hexidecimal value notifying the receiver of the size of the data chunk to follow. Initialize a byte array to this value, then call this method to fill the byte array.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

SegmentedStream Class  | SegmentedStream Members  | Overload List


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.